// 左移运算符重载 <<
// 输出自定义数据类型
#include <iostream>
using namespace std;
class Box {
    // 通过友元实现该函数访问类私有变量
    friend ostream& operator<<(ostream& cout, const Box& box);
private:
    int m_volume;
    int m_price;
public:
    Box();
    Box(int volume, int price);
};
Box::Box() {}
Box::Box(int volume, int price) {
    this->m_volume = volume;
    this->m_price = price;
}
// 重载左移运算符一般通过全局函数
// 返回引用为了实现链式编程
ostream& operator<<(ostream &cout, const Box &box) {
    cout << "volume = " << box.m_volume << endl;
    cout << "price = " << box.m_price;
    return cout;
}
void test1() {
    Box b1(10, 30);
    cout << b1 << endl;

}
int main(void) {
    test1();
    
    return 0;
} 